<script>
import DashTable from '@/components/dashtable/DashTable';

//表格组件
export default {
  name: 'FormCard',
  components: {
    DashTable,
  },
  props: {
    allOptions: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },
  computed: {
    //转换表格设置
    options() {
      if (!this.allOptions) return {};
      //设置显示列
      let columns = [];
      let excludeFields = this.allOptions.settings.excludeFields || []; //显示字段
      if (this.allOptions.data.rows.length > 0) {
        columns = Object.keys(this.allOptions.data.rows[0])
          .filter(p => excludeFields.indexOf(p) < 0)
          .map(p => {
            return { key: p, title: p };
          });
      }
      return {
        columns,
        data: this.allOptions.data.rows,
        ...this.allOptions.settings,
      };
    },
  },
  render(createElement) {
    return createElement('DashTable', {
      props: this.options,
    });
  },
};
</script>


<style lang="less" scoped>
</style>
